Skip to content

test(hub): isolate Vitest state and worker databases - #112

Merged
nshki merged 6 commits into
copilot/hub-postgres-prismafrom
copilot/hub-vitest-isolation
Oct 26, 2026
Merged

nshki merged 6 commits into
copilot/hub-postgres-prismafrom
copilot/hub-vitest-isolation

Conversation

Copilot AI commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Why

Hub contributors need independent test cases without repeating cleanup hooks in every file. Database tests also need to run in parallel without sharing records or clearing the development database. Closes #111.

This PR follows #108 in a native GitHub stack.

What changes

Shared setup resets test state before each case. It resets mocks, restores environment variables and real timers, and clears browser storage and leftover document content. Tests no longer repeat those cleanup hooks. They must still close resources they create, such as listeners and servers.

Vitest runs files in parallel and keeps cases within each worker sequential. Node.js and jsdom tests can opt into database access with .db.test.ts or .db.test.tsx files. Database-enabled projects share the setup code but use separate databases per project and worker, prepared with the current Prisma schema. Before each case, setup clears application records and resets generated identity counters. It preserves migration records. Simultaneous runs use different database names, and cleanup drops only databases created by that run.

npm test does not require PostgreSQL. npm run test:database selects both node-database and browser-database using TEST_DATABASE_URL. Only this CI command starts PostgreSQL. The testing guide explains setup and cleanup and requires each case to arrange its own records, act, and assert.

The schema and migration files live under hub/schema/. Setup-only browser and database tests are removed. The database test command allows an empty project to pass; there are no database cases yet, so current runs do not exercise database setup.

CI runs individual checks on every pull request, regardless of which files changed. Jobs no longer combine other jobs' results into a required check. Scripts CI checks the maintenance scripts independently. Hub's test jobs are named Hub unit tests and Hub database tests.

Repository branch rules are unchanged. Maintainers must update required check names when adopting these workflows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI requested review from a team and nshki as code owners October 23, 2026 23:39
Copilot AI max review requested due to automatic review settings October 23, 2026 23:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because there is no eligible user to bill.

An enterprise owner can allow the organization to be billed for reviews like this by enabling Copilot code review for users without a license.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI added this pull request to stack #115 October 26, 2026 14:55
Copilot AI and others added 4 commits October 26, 2026 15:05
Rename the maintenance workflow and checks to Scripts CI.

Co-authored-by: Nishiki Liu <hello@nshki.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move Prisma schema and migrations to schema/.

Co-authored-by: Nishiki Liu <hello@nshki.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Nishiki Liu <hello@nshki.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Nishiki Liu <hello@nshki.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@nshki
nshki merged commit 3f10ad0 into build/hub/new Oct 26, 2026
26 checks passed
@nshki
nshki deleted the copilot/hub-vitest-isolation branch October 26, 2026 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants